home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / DSI020.ARC / CLOCK.ASM next >
Assembly Source File  |  1988-09-08  |  2KB  |  68 lines

  1. ;    CLOCK.ASM
  2. ;
  3. ;    Author:        M. Steven Baker
  4. ;    Date:        September 8, 1988
  5. ;
  6. ;    clock() routine for SVS C (only)
  7. ;
  8. ;    
  9. ;;    C CODE TO RUN THIS:
  10. ;;    extern long clock();
  11. ;
  12. ;    Written for the SVS assembler (ASM68K.E20)
  13. ;    by M. Steven Baker (Technical Editor -- Programmer's Journal)
  14. ;
  15. ;    note:    since dumb SVS assembler doesn't support
  16. ;        EXTB.L    D0
  17. ;    we use
  18. ;        ANDI    #$FF,D0
  19. ;        EXT.L    D0
  20. ;
  21. ;
  22.     global    clock
  23. ;
  24. ;    return time in HH:MM:SS format
  25. ;
  26. clock    MOVEM.L    D2,-(SP)    ; save D2
  27.     MOVEQ    #28,D0        ; GET TIME
  28.     TRAP    #14        ; D0=HH:MM:SS:xx
  29.     MOVE.L    D0,D1        ; SAVE REGISTER
  30.     SWAP    D0        ; get hour to low word
  31.     ASR.W    #8,D0        ; SHIFT IN hour
  32.     EXT.L    D0        ; extend to a long word
  33.     MOVEQ    #60,D2        ; multiply by 60 minutes
  34.     MULU.W    D0,D2        ; multiply and save it in D2
  35. ;
  36.     MOVE.L    D1,D0        ; now get minutes
  37.     SWAP    D0        ;   INTO LOW WORD
  38.     ANDI    #$FF,D0        ; screen out all but low byte
  39.     EXT.L    D0        ; extend to a long word
  40.     ADD.L    D0,D2        ; add minutes to D2
  41.     MOVEQ    #60,D0        
  42.     MULU.W    D0,D2        ; now convert to seconds
  43. ;    
  44.     MOVE.L    D1,D0        ; now get seconds
  45.     ASR.W    #8,D0        ; SHIFT seconds into low byte
  46.     EXT.L    D0        ; extend to a long word
  47.     ADD.L    D0,D2        ; add in seconds
  48.                 ;now convert to 1/100s of seconds
  49.     MOVE.L    D2,D0        ; save x1
  50.     ASL.L    #2,D2        ; x 4 
  51.     ADD.L    D0,D2        ; x 5
  52.     MOVE.L    D2,D0        ; and save x5
  53.     ASL.L    #2,D0        ; x 20
  54.     ADD.L    D2,D0        ; x 25
  55.     ASL.L    #2,D0        ; x 100
  56. ;
  57.                 ; now get 1/100 seconds
  58.     ANDI    #$FF,D1        ; screen out all but low byte
  59.     EXT.L    D1        ; extend to a long word
  60.     ADD.L    D1,D0        ; add into D0
  61.     MOVEM.L    (SP)+,D2
  62.  
  63.     RTS            ; just return for 2.8
  64. ;
  65. ;    RTD    #16        ; return and deallocate for FORTRAN 2.6
  66. ;
  67.     END
  68.